//
//  AGDCVideoFrameObserver.hpp
//  AgoraDemo
//
//  Created by tzx on 16/10/17.
//  Copyright © 2016年 apple. All rights reserved.
//

#ifndef AGDCVideFrame_hpp
#define AGDCVideFrame_hpp

#include <stdio.h>

#include <iostream>

using namespace std;

#include <AgoraRtcEngineKit/IAgoraMediaEngine.h>

//#include "VideoFrameBufferPool.h"
//#include "ColorSpaceConvert.h"

#include "mediaProcess.h"


using VideoOutputCallback = std::function<void(uint8_t* data, size_t size, int w, int h, int rawType, bool isMain, void *context)>;


//@class AGDChatViewController;
#import "AGDChatViewController.h"

class CVideoFrameObserver:public agora::media::IVideoFrameObserver
{
public:
    CVideoFrameObserver();
    ~CVideoFrameObserver();
public:
    bool onCaptureVideoFrame(VideoFrame& videoFrame);
    bool onRenderVideoFrame(unsigned int uid, VideoFrame& videoFrame);
    
    bool inputVideoFrame(uint8_t *data, int len, int width, int height, int rawType);
    
    void setCallback(VideoOutputCallback callback, void *context){m_callback = callback;m_context = context;}

    
private:
    uint8_t                     *mYuvBuf;
    VideoOutputCallback         m_callback;
    void                        *m_context;
    void*                       *mVideoFrameBufferPool; // critical value
    
    int                         mWidth;
    int                         mHeight;
    
    AGDChatViewController       *ocController;
    
};

#endif /* AGDCVideFrame_hpp */
